#include <cppunit/config/SourcePrefix.h>
#include "UsesTest.h"
#include <iostream>
#include <string>

using namespace std;

void UsesTest::setUp() {}
void UsesTest::tearDown() {}

CPPUNIT_TEST_SUITE_REGISTRATION( UsesTest );

// method to test the setting and retrieval of Uses relationship
void UsesTest::testSetUsesStmtAndGetUsedByStmt() 
{
	cout << "Testing : void setUsesStmt(INDEX, INDEX)" << endl;
	cout << "and INDEX_SET getUsedByStmt(INDEX)" << endl;
	VarTable* vt;
	StmtTable *st;
	ProcTable *pt;
	vt = new VarTable();
	st = new StmtTable();
	pt = new ProcTable();
	uses = new Uses(vt, st, pt);
	set<int> indexSet;	

	// set some Uses relationships
	uses->setUsesStmtUses(5, 3);
	uses->setUsesStmtUses(7, 9);
		
	// verify that the assignment is corrects

	indexSet = uses->getUsedIndexUses(5);
	CPPUNIT_ASSERT_EQUAL(3, *indexSet.begin());
	
	indexSet = uses->getUsedIndexUses(7);
	CPPUNIT_ASSERT_EQUAL(9, *indexSet.begin());

	cout << "Test OK  : void setUsesStmt(INDEX, INDEX)" << endl;
	cout << "and INDEX_SET getUsedByStmt(INDEX)" << endl;
}

